package br.mg.bhe.ftpobre.log;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.JEditorPane;

import br.mg.bhe.ftpobre.gui.MainFrame;

/**
 * 
 * @author Aureliano
 */
public class FtpLogView {

    private FtpLogView() {
        super();
    }

    public static void log(String message) {
        addTextToLogView(message);
    }

    private static void addTextToLogView(String message) {                	
        JEditorPane editor = MainFrame.getInstance().getEditorPaneLog();
        message = editor.getText() + (editor.getText().length() > 0 ? "\n" : "") + agora() + ": " + message;
        MainFrame.getInstance().getEditorPaneLog().setText(message);
    }
    
    private static String agora() {
    	return new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")
    		.format(new Date(System.currentTimeMillis()));
    }
}
